/*
ID: zedongl1
PROG: ride
LANG: C++
*/
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
    ifstream fin("ride.in");
    ofstream fout("ride.out");
    char ch1[6],ch2[6];
    int sum1=1,sum2=1,m1,m2;
    fin>>ch1;
    fin>>ch2;
    m1=strlen(ch1);
    m2=strlen(ch2);
    for(int i=0;i<m1;i++)
            sum1=sum1*(int)(ch1[i]-'@');
    for(int j=0;j<m2;j++)   
            sum2=sum2*(int)(ch2[j]-'@');
    if(sum1%47==sum2%47)  fout<<"GO"<<endl;
    else                  fout<<"STAY"<<endl;
    return 0;
}
    
     
